<?php
include 'Phpmailer.php';
/**
 * 发送电子邮件类
 * @package Tool
 * @subpackage Email
 * @version 1.0
 */

class Sendmail
{
    private $_phpmail;
    private $_host;
    private $_port;
    private $_charset;
    private $_subje;
    /**
     * 构造函数
     *
     * @param 邮件发送者地址 $sender_email
     * @param 邮件发送者名字 $sender_name
     */
    function __construct($sender_email = 'virowin@sohu.com' , $sender_name = '活动'  )
    {
        $this->_phpmail = new Phpmailer();
        $this->_phpmail->IsSMTP();
        $this->_phpmail->SMTPAuth = false;
//        $this->_phpmail->Host = '192.168.95.54';
       	$this->_phpmail->Host = '10.10.124.223';
        $this->_phpmail->Port = 25;
        $this->_phpmail->CharSet = 'utf-8';
        $this->_phpmail->SetFrom($sender_email, $sender_name);
    }
    function __destruct(){}
    
    public function setOptions($options)
    {
        if (isset($options['subject']))
        {
            $this->_phpmail->Subject = $options['subject'];
        }
        if (isset($options['altbody']))
        {
            $this->_phpmail->AltBody = $options['altbody'];
        }
        if (isset($options['message']))
        {
            $this->_phpmail->MsgHTML($options['message']);
        }
        if (isset($options['message']))
        {
            $this->_phpmail->MsgHTML($options['message']);
        }
       
        if (isset($options['encoding']))
        {
            $this->_phpmail->Encoding = $options['encoding'];
        }
       
        if (isset($options['charset']))
        {
            $this->_phpmail->CharSet= $options['charset'];
        }
        
    }
    
    public function addAddress($email,$name)
    {
        $this->_phpmail->AddAddress($email,$name);
    }

    /**
     * 设置内容
     * 
     * @access public
     * @author virowin<virowin@gmail.com>
     * @param string $body 内容
     * @return void
     */
    
    public function setBody($body)
    {
        $this->_phpmail->Body = $body;
    } 
    /**
     * 设置标题
     * 
     * @access public
     * @author virowin<virowin@gmail.com>
     * @param string $subject 内容
     * @return void
     */
    
    public function setSubject($subject)
    {
        $this->_phpmail->Subject = $subject;
    } 
    /**
     * 设置是否HTML格式
     * 
     * @access public
     * @author virowin<virowin@gmail.com>
     * @param boolean $bol 是否
     * @return void
     */   
    public function setHTML($bol = true)
    {
        $this->_phpmail->IsHTML($bol);
    }
    /**
     * 设置格式
     * 
     * @access public
     * @author virowin<virowin@gmail.com>
     * @param string $charset 字符格式
     * @return void
     */   
    public function setCharSet($charset = 'utf-8')
    {
        $this->_phpmail->CharSet = $charset;
    }
    public function send()
    {
        return $this->_phpmail->Send();
    }
    
    public function getErrorInfo()
    {
        return $this->_phpmail->ErrorInfo;
    }
}
